<?php 
  // Start the SESSION vars
	if (session_id() == "")
	{
		session_start();
	}
	// Include configuration variables
  include_once('/var/www/gde-1.0/htdocs/config.php');
  // Include the login top.php
  include_once(Config::base_path.Config::top_login_php); 
  // Include the login nav.php
  include_once(Config::base_path.Config::nav_login_php); 
   // Include builder functions
  include_once(Config::base_path.Config::builder_func_path."builder.func.php"); 

 // Selected database must be set
 if($_SESSION['selected_database'] != "")
 {
    // Set the session vars for the inner join tables based on selections posted from builder-3.php
    foreach ($_SESSION['selected_table'] as $table)
    {
       $_SESSION['selected_table_join_'.$table] = $_POST['selected_table_join_'.$table];
       $_SESSION['selected_table_where_'.$table] = $_POST['selected_table_where_'.$table];
       $_SESSION['selected_table_text_'.$table] = $_POST['selected_table_text_'.$table];
    }
    
    // Build the query string from the user selected builder options
    $query_string = buildQueryString();

    // Present the query editor with the user build query to be run or edited.
    queryEditor($query_string);
 }
 else // Not set, pass empty query string so user can make there own query
 {
   queryEditor("");
 }
 ?>

